Imports System
Imports System.Collections
Imports ribs.DataAccessLayer

Namespace BusinessLogicLayer
    Public Class ActionSummaryCollection
        Inherits CollectionBase

        Default Public Property Item(ByVal index As Integer) As ActionSummary
            Get
                Return CType(List(index), ActionSummary)
            End Get
            Set(ByVal value As ActionSummary)
                List(index) = value
            End Set
        End Property

        Public Function InList(ByVal value As ActionSummary) As Integer
            For iCtr As Int32 = 0 To List.Count
                Dim xAction As New ActionSummary(List(iCtr))
                If (value.Action = xAction.Action) And _
                                (value.User.ToUpper = xAction.User.ToUpper) Then
                    Return iCtr
                Else
                    Return DefaultValues.NotFound
                End If
            Next
            Return DefaultValues.NotFound
        End Function 'Add

        Public Function Add(ByVal value As ActionSummary) As Integer
            Return List.Add(value)
        End Function 'Add

        Public Function IndexOf(ByVal value As ActionSummary) As Integer
            Return List.IndexOf(value)
        End Function 'IndexOf

        Public Sub Insert(ByVal index As Integer, ByVal value As ActionSummary)
            List.Insert(index, value)
        End Sub 'Insert

        Public Sub Remove(ByVal value As ActionSummary)
            List.Remove(value)
        End Sub 'Remove

        Public Function Contains(ByVal value As ActionSummary) As Boolean
            ' If value is not of type Project, this will return false.
            Return List.Contains(value)
        End Function 'Contains


        Protected Overrides Sub OnInsert(ByVal index As Integer, ByVal value As Object)
            If Not value.GetType() Is Type.GetType("ribs.BusinessLogicLayer.ActionSummary") Then
                Throw New ArgumentException("value must be of type ActionSummary.", "value")
            End If
        End Sub 'OnInsert

        Protected Overrides Sub OnRemove(ByVal index As Integer, ByVal value As Object)
            If Not value.GetType() Is Type.GetType("ribs.BusinessLogicLayer.ActionSummary") Then
                Throw New ArgumentException("value must be of type ActionSummary.", "value")
            End If
        End Sub 'OnRemove

        Protected Overrides Sub OnSet(ByVal index As Integer, ByVal oldValue As Object, ByVal newValue As Object)
            If Not newValue.GetType() Is Type.GetType("ribs.BusinessLogicLayer.ActionSummary") Then
                Throw New ArgumentException("newValue must be of type ActionSummary.", "newValue")
            End If
        End Sub 'OnSet

        Protected Overrides Sub OnValidate(ByVal value As Object)
            If Not value.GetType() Is Type.GetType("ribs.BusinessLogicLayer.ActionSummary") Then
                Throw New ArgumentException("value must be of type ActionSummary.")
            End If
        End Sub 'OnValidate

    End Class
End Namespace


